﻿using AiXiu.BLL;
using AiXiu.IBLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AiXiu.WebSite
{
    public partial class UserList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            IUserManager userManager = new UserManager();
            gvUserList.DataSource= userManager.GetList();
            gvUserList.DataBind();

        }

        protected void gvUserList_RowEditing(object sender, GridViewEditEventArgs e)
        {
            string userId = gvUserList.Rows[e.NewEditIndex].Cells[0].Text;//取出要删除记录的主键值

            Response.Redirect("UserEdit.aspx?Id="+userId);
        }

        protected void gvUserList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string userId = gvUserList.Rows[e.RowIndex].Cells[0].Text;//取出要删除记录的主键值

        }

        protected void gvUserList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.Cells[2].Text == "0")
                {
                    e.Row.Cells[2].Text = "未知";
                }
                if (e.Row.Cells[2].Text == "1")
                {
                    e.Row.Cells[2].Text = "男";
                    e.Row.Cells[7].Text = "上架";
                }
                if (e.Row.Cells[2].Text == "2")
                {
                    e.Row.Cells[2].Text = "女";
                    e.Row.Cells[7].Text = "下架";
                }
            }

        }
    }
}